﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.NetworkInformation;

namespace Dossert
{
    public partial class MainForm : Form
    {
        //SynFlooder g_SynFlooder;
        Flooder m_Flooder = new Flooder();

        public MainForm()
        {
            InitializeComponent();
            listMethods.SelectedIndex = 1;

            //LivePcapDeviceList devList = LivePcapDeviceList.Instance;
            //if (devList.Count < 1)
            //    return;

            //FlooderInfo info = new FlooderInfo(devList[1], "98.137.149.56", 80);
            //g_SynFlooder = new SynFlooder(info);
            //g_SynFlooder.CreatePacket();
        }

        private void btnFire_Click(object sender, EventArgs e)
        {
            if (m_Flooder.IsFiring)
            {
                m_Flooder.Stop();
                btnFire.Text = "Fuhren!";
            }

            else
            {
                btnUpdate_Click(this, null);
                btnFire.Text = "Stop";
                m_Flooder.Start();
            }
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                m_Flooder.Address = txtIP.Text;
            }

            catch (System.FormatException)
            {
                m_Flooder.Address = IPAddress.None.ToString();
            }

            m_Flooder.Port = (ushort)numPort.Value;
            m_Flooder.NumThreads = (uint)numThreads.Value;
            m_Flooder.Message = txtMessage.Text;

            switch (listMethods.SelectedItems[0].ToString())
            {
                case "TCP": m_Flooder.Method = FloodMethod.TCP; break;
                case "UDP": m_Flooder.Method = FloodMethod.UDP; break;
                default: m_Flooder.Method = FloodMethod.TCP; break;
            }
        }
    }
}
